package top.mschen.blog.controller.oauth;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import top.mschen.blog.common.utils.WebUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 2018/4/19
 * <p>
 * starup
 *
 * @author Shengzhao Li
 */
@Controller
public class SOSController {


    private static final Logger LOG = LoggerFactory.getLogger(SOSController.class);


    /**
     * 首页
     */
    @RequestMapping(value = "/")
    public String index(Model model) {
        return "jsp/index";
    }


    //Go login
    @GetMapping(value = {"/login"})
    public String login(Model model) {
        LOG.info("Go to login, IP: {}", WebUtils.getIp());
        return "jsp/login";
    }

    //Go login
    @GetMapping(value = {"/login1"})
    public ModelAndView login1(Model model) {

        ModelAndView emailTemplate = new ModelAndView("emailTemplate");
        emailTemplate.addObject("user","hello world!");
        return emailTemplate;
    }

    //Go login
    @GetMapping(value = {"/login2"})
    @ResponseBody
    public Map login2(Model model) {
        Map hashMap = new HashMap();
        hashMap.put("a","asfda");
        return hashMap;
    }
}
